"use strict";
cc._RF.push(module, '725a4lOLatARqR6r3f6EqHJ', 'LevelLianXian20Item');
// scripts/modes/normalMode/levelLianXian/level20/LevelLianXian20Item.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameEngine_1 = require("../../../../engines/gameEngine");
var LevelLianXian_1Item_1 = require("../base/LevelLianXian_1Item");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var LevelLianXian11Item = /** @class */ (function (_super) {
    __extends(LevelLianXian11Item, _super);
    function LevelLianXian11Item() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    LevelLianXian11Item.prototype.moveComponentCancel = function (touchEvent) {
        var _this = this;
        var _a;
        if (!this.level1Script.canTouch)
            return;
        if (!this.level1Script.isPlaySound && this.level1Script.currentSelectNode) {
            // this.level1Script.leftNode.children.forEach((n:cc.Node)=>{
            //     n.scale = 1;
            // });
            // this.level1Script.rightNode.children.forEach((n:cc.Node)=>{
            //     n.scale = 1;
            // });
            this.level1Script.currentSelectNode.scale = 1;
            this.level1Script.redrawAllPointPath();
            var tag = this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item_1.default).tagNum;
            var isIndexLeft = this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item_1.default).nodeRotation == 0;
            var currentNum = (_a = this.level1Script.afterSelectNode) === null || _a === void 0 ? void 0 : _a.getComponent(LevelLianXian_1Item_1.default).currentNum;
            if (this.level1Script.afterSelectNode && tag.includes(currentNum) && this.level1Script.afterSelectNode && (this.level1Script.afterSelectNode.getComponent(LevelLianXian_1Item_1.default).currentNum != this.nowLianNum || this.currentNum == -1)) {
                this.level1Script.afterSelectNode.scale = 1;
                this.level1Script.redrawAllPointPath();
                this.currentColors();
                this.bingo(this.getNodePos(this.level1Script.currentSelectNode), this.getNodePos(this.level1Script.afterSelectNode), this.currentColor, this.level1Script.afterSelectNode);
                var index = this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item_1.default).currentNum;
                this.bingoAni(currentNum, index, isIndexLeft);
                this.changeAniNode(false);
                this.level1Script.afterSelectNode.getComponent(LevelLianXian_1Item_1.default).changeAniNode(false);
                this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item_1.default).itemBg.color = this.currentColor;
                this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item_1.default).itemBg.active = true;
                this.level1Script.afterSelectNode.getComponent(LevelLianXian_1Item_1.default).itemBg.color = this.currentColor;
                this.level1Script.afterSelectNode.getComponent(LevelLianXian_1Item_1.default).itemBg.active = true;
                // this.le
                var path = this.level1Script.levelName + "/" + this.level1Script.sounds[currentNum - 1];
                this.level1Script.isAllCheckDone();
                if (this.sigleSound != "") {
                    gameEngine_1.managers().soundMgr.stopAllSound();
                    path = this.level1Script.levelName + "/" + this.sigleSound;
                    gameEngine_1.managers().soundMgr.playSound(path, function () {
                        _this.level1Script.checkWin();
                    });
                }
                else {
                    if (this.level1Script.sounds[currentNum - 1] && this.level1Script.sounds[currentNum - 1] != "") {
                        gameEngine_1.managers().soundMgr.playSound(path, function () {
                            _this.level1Script.checkWin();
                        });
                    }
                    else {
                        // if (this.sigleSound == "" || this.sigleSound == null) {
                        this.level1Script.checkWin();
                        // }
                    }
                }
                // if(this.sigleSound != ""){
                //     managers().soundMgr.stopAllSound();
                //     path = this.level1Script.levelName+"/sound/" + this.sigleSound;
                //     managers().soundMgr.playSound(path,()=>{
                //         // this.level1Script.checkWin();
                //     });
                // }else{
                //     if(this.level1Script.sounds[currentNum - 1] == null || this.level1Script.sounds[currentNum-1] == ""){
                //         // this.level1Script.checkWin();
                //     }
                // }
                if ((this.level1Script.sounds[currentNum - 1] == null || this.level1Script.sounds[currentNum - 1] == "") && (this.level1Script.sounds[currentNum - 1] && this.level1Script.sounds[currentNum - 1] != "")) {
                    // this.level1Script.checkWin();
                }
                /** 答对之后，停止音效 */
                if (this.level1Script.isPlaySoundNode) {
                    gameEngine_1.managers().soundMgr.stopAllSound();
                    this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1.default).isStartSoundTime = false;
                    this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1.default).currentTime = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1.default).oldSoundTime;
                    var num2 = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1.default).currentTime.toFixed(1);
                    this.level1Script.isPlaySoundNode.getChildByName("timeLabel").getComponent(cc.Label).string = "" + num2 + "s";
                    this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1.default).soundAni.play("soundAniIdle");
                }
                this.level1Script.isPlaySound = false;
                this.level1Script.isPlaySoundNode = null;
                this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item_1.default).isBuNengSelect = true;
                this.level1Script.currentSelectNode = null;
                this.level1Script.afterSelectNode.scale = 1;
                this.level1Script.redrawAllPointPath();
                this.level1Script.afterSelectNode = null;
                return;
            }
            else if (this.level1Script.afterSelectNode) {
                this.level1Script.errorSubTime();
                gameEngine_1.managers().soundMgr.playSound('mainSound/error'); // 错误音效
                this.level1Script.currentSelectNode = null;
                this.level1Script.afterSelectNode.scale = 1;
                this.level1Script.redrawAllPointPath();
                this.level1Script.afterSelectNode = null;
                this.level1Script.ctx1.clear();
                this.level1Script.cishuNum = 1;
                return;
            }
            else {
                this.level1Script.currentSelectNode = null;
                this.level1Script.ctx1.clear();
                this.level1Script.cishuNum = 1;
                return;
            }
        }
    };
    LevelLianXian11Item = __decorate([
        ccclass
    ], LevelLianXian11Item);
    return LevelLianXian11Item;
}(LevelLianXian_1Item_1.default));
exports.default = LevelLianXian11Item;

cc._RF.pop();